package cn.ibizlab.odoo.core.odoo_sale.service.impl;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.math.BigInteger;
import java.util.Collection;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import cn.ibizlab.odoo.core.client.model.Isale_order_line;
import cn.ibizlab.odoo.core.odoo_sale.domain.Sale_order_line;
import cn.ibizlab.odoo.core.odoo_sale.filter.Sale_order_lineSearchContext;
import cn.ibizlab.odoo.core.odoo_sale.service.ISale_order_lineService;
import cn.ibizlab.odoo.util.SearchResult;
import cn.ibizlab.odoo.util.log.IBIZLog;

/**
 * 实体[销售订单行] 服务对象接口实现
 */
@Slf4j
@IBIZLog
@Service
public class Sale_order_lineServiceImpl implements ISale_order_lineService {

    @Autowired
    private cn.ibizlab.odoo.core.client.service.Isale_order_lineClientService sale_order_lineClientService;

    @Override
    public Sale_order_line get(Integer id) {
        Isale_order_line clientModel = sale_order_lineClientService.createModel();
        clientModel.setId(id);
        sale_order_lineClientService.get(clientModel) ;
        return this.convert2Domain(clientModel,null);
    }

    @Override
    public Sale_order_line get(Sale_order_line sale_order_line) {
        Sale_order_line retsale_order_line = this.get(sale_order_line.getId()) ;
    	BeanCopier copier=BeanCopier.create(retsale_order_line.getClass(), sale_order_line.getClass(), false);
        copier.copy(retsale_order_line, sale_order_line, null);
        return sale_order_line ;
    }

    @Override
    public boolean remove(Integer id) {
        boolean bOk = false ;
        Isale_order_line clientModel = sale_order_lineClientService.createModel();
        clientModel.setId(id);
        sale_order_lineClientService.remove(clientModel) ;
        bOk = true ;
        return bOk ;
    }

    @Override
    public void createBatch(List<Sale_order_line> sale_order_lines, int batchSize) {

                        //sale_order_lineClientService.createBatch(sale_order_lines,batchSize) ;

    }

    @Override
    public boolean update(Sale_order_line sale_order_line) {
        boolean bOk = false ;
        Isale_order_line clientModel = this.convert2Model(sale_order_line,null);
        sale_order_lineClientService.update(clientModel) ;
        this.convert2Domain(clientModel,sale_order_line) ;
        bOk = true;
        return bOk ;
    }

    @Override
    public boolean create(Sale_order_line sale_order_line) {
        boolean bOk = false ;
        Isale_order_line clientModel = this.convert2Model(sale_order_line,null);
        sale_order_lineClientService.create(clientModel) ;
        this.convert2Domain(clientModel,sale_order_line);
        bOk = true ;

        return bOk ;
    }

    @Override
    public void removeBatch(Collection<? extends Serializable> idList, int batchSize) {

        //sale_order_lineClientService.removeBatch(sale_order_lines) ;

    }

    @Override
    public void updateBatch(List<Sale_order_line> sale_order_lines, int batchSize) {

        //sale_order_lineClientService.updateBatch(sale_order_lines,batchSize) ;

    }

    /**
     * 查询集合 默认查询
     */
    @Override
    public Page<Sale_order_line> searchDefault(Sale_order_lineSearchContext context) {
        List<Sale_order_line> list = new ArrayList<Sale_order_line>();
        Page<cn.ibizlab.odoo.core.client.model.Isale_order_line> clientModelList = sale_order_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Isale_order_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Sale_order_line>(list, context.getPageable(), clientModelList.getTotalElements());
    }


    /**
     * 根据活动入场券查询
     */
    @Override
    public Page<Sale_order_line> selectByOdoo_event_ticket(Integer id){
        Sale_order_lineSearchContext context = new Sale_order_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Sale_order_line> list = new ArrayList<Sale_order_line>();
        Page<cn.ibizlab.odoo.core.client.model.Isale_order_line> clientModelList = sale_order_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Isale_order_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Sale_order_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据活动查询
     */
    @Override
    public Page<Sale_order_line> selectByOdoo_event(Integer id){
        Sale_order_lineSearchContext context = new Sale_order_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Sale_order_line> list = new ArrayList<Sale_order_line>();
        Page<cn.ibizlab.odoo.core.client.model.Isale_order_line> clientModelList = sale_order_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Isale_order_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Sale_order_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据产品包装查询
     */
    @Override
    public Page<Sale_order_line> selectByOdoo_product_packaging(Integer id){
        Sale_order_lineSearchContext context = new Sale_order_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Sale_order_line> list = new ArrayList<Sale_order_line>();
        Page<cn.ibizlab.odoo.core.client.model.Isale_order_line> clientModelList = sale_order_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Isale_order_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Sale_order_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据产品查询
     */
    @Override
    public Page<Sale_order_line> selectByOdoo_product(Integer id){
        Sale_order_lineSearchContext context = new Sale_order_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Sale_order_line> list = new ArrayList<Sale_order_line>();
        Page<cn.ibizlab.odoo.core.client.model.Isale_order_line> clientModelList = sale_order_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Isale_order_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Sale_order_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据公司查询
     */
    @Override
    public Page<Sale_order_line> selectByOdoo_company(Integer id){
        Sale_order_lineSearchContext context = new Sale_order_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Sale_order_line> list = new ArrayList<Sale_order_line>();
        Page<cn.ibizlab.odoo.core.client.model.Isale_order_line> clientModelList = sale_order_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Isale_order_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Sale_order_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据币种查询
     */
    @Override
    public Page<Sale_order_line> selectByOdoo_currency(Integer id){
        Sale_order_lineSearchContext context = new Sale_order_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Sale_order_line> list = new ArrayList<Sale_order_line>();
        Page<cn.ibizlab.odoo.core.client.model.Isale_order_line> clientModelList = sale_order_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Isale_order_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Sale_order_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据联系人查询
     */
    @Override
    public Page<Sale_order_line> selectByOdoo_order_partner(Integer id){
        Sale_order_lineSearchContext context = new Sale_order_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Sale_order_line> list = new ArrayList<Sale_order_line>();
        Page<cn.ibizlab.odoo.core.client.model.Isale_order_line> clientModelList = sale_order_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Isale_order_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Sale_order_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Sale_order_line> selectByOdoo_create(Integer id){
        Sale_order_lineSearchContext context = new Sale_order_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Sale_order_line> list = new ArrayList<Sale_order_line>();
        Page<cn.ibizlab.odoo.core.client.model.Isale_order_line> clientModelList = sale_order_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Isale_order_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Sale_order_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Sale_order_line> selectByOdoo_salesman(Integer id){
        Sale_order_lineSearchContext context = new Sale_order_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Sale_order_line> list = new ArrayList<Sale_order_line>();
        Page<cn.ibizlab.odoo.core.client.model.Isale_order_line> clientModelList = sale_order_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Isale_order_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Sale_order_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Sale_order_line> selectByOdoo_write(Integer id){
        Sale_order_lineSearchContext context = new Sale_order_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Sale_order_line> list = new ArrayList<Sale_order_line>();
        Page<cn.ibizlab.odoo.core.client.model.Isale_order_line> clientModelList = sale_order_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Isale_order_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Sale_order_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据销售订单行查询
     */
    @Override
    public Page<Sale_order_line> selectByOdoo_linked_line(Integer id){
        Sale_order_lineSearchContext context = new Sale_order_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Sale_order_line> list = new ArrayList<Sale_order_line>();
        Page<cn.ibizlab.odoo.core.client.model.Isale_order_line> clientModelList = sale_order_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Isale_order_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Sale_order_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据销售订单查询
     */
    @Override
    public Page<Sale_order_line> selectByOdoo_order(Integer id){
        Sale_order_lineSearchContext context = new Sale_order_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Sale_order_line> list = new ArrayList<Sale_order_line>();
        Page<cn.ibizlab.odoo.core.client.model.Isale_order_line> clientModelList = sale_order_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Isale_order_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Sale_order_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据库存路线查询
     */
    @Override
    public Page<Sale_order_line> selectByOdoo_route(Integer id){
        Sale_order_lineSearchContext context = new Sale_order_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Sale_order_line> list = new ArrayList<Sale_order_line>();
        Page<cn.ibizlab.odoo.core.client.model.Isale_order_line> clientModelList = sale_order_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Isale_order_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Sale_order_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据产品计量单位查询
     */
    @Override
    public Page<Sale_order_line> selectByOdoo_product_uom(Integer id){
        Sale_order_lineSearchContext context = new Sale_order_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Sale_order_line> list = new ArrayList<Sale_order_line>();
        Page<cn.ibizlab.odoo.core.client.model.Isale_order_line> clientModelList = sale_order_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Isale_order_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Sale_order_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }



    public Isale_order_line convert2Model(Sale_order_line domain , Isale_order_line model) {
        if(domain == null)
            return model ;
        if(model==null){
            model = sale_order_lineClientService.createModel() ;
        }

         if(domain.getIs_expenseDirtyFlag())
            model.setIs_expense(domain.getIs_expense());
         if(domain.getWrite_dateDirtyFlag())
            model.setWrite_date(domain.getWrite_date());
         if(domain.getQty_to_invoiceDirtyFlag())
            model.setQty_to_invoice(domain.getQty_to_invoice());
         if(domain.getAnalytic_tag_idsDirtyFlag())
            model.setAnalytic_tag_ids(domain.getAnalytic_tag_ids());
         if(domain.getWarning_stockDirtyFlag())
            model.setWarning_stock(domain.getWarning_stock());
         if(domain.getIdDirtyFlag())
            model.setId(domain.getId());
         if(domain.getDisplay_nameDirtyFlag())
            model.setDisplay_name(domain.getDisplay_name());
         if(domain.getPrice_reduce_taxexclDirtyFlag())
            model.setPrice_reduce_taxexcl(domain.getPrice_reduce_taxexcl());
         if(domain.getProduct_custom_attribute_value_idsDirtyFlag())
            model.setProduct_custom_attribute_value_ids(domain.getProduct_custom_attribute_value_ids());
         if(domain.getQty_delivered_manualDirtyFlag())
            model.setQty_delivered_manual(domain.getQty_delivered_manual());
         if(domain.getPrice_taxDirtyFlag())
            model.setPrice_tax(domain.getPrice_tax());
         if(domain.getQty_delivered_methodDirtyFlag())
            model.setQty_delivered_method(domain.getQty_delivered_method());
         if(domain.getInvoice_statusDirtyFlag())
            model.setInvoice_status(domain.getInvoice_status());
         if(domain.getDisplay_typeDirtyFlag())
            model.setDisplay_type(domain.getDisplay_type());
         if(domain.getMove_idsDirtyFlag())
            model.setMove_ids(domain.getMove_ids());
         if(domain.getUntaxed_amount_invoicedDirtyFlag())
            model.setUntaxed_amount_invoiced(domain.getUntaxed_amount_invoiced());
         if(domain.getProduct_no_variant_attribute_value_idsDirtyFlag())
            model.setProduct_no_variant_attribute_value_ids(domain.getProduct_no_variant_attribute_value_ids());
         if(domain.get__last_updateDirtyFlag())
            model.set__last_update(domain.get__last_update());
         if(domain.getIs_downpaymentDirtyFlag())
            model.setIs_downpayment(domain.getIs_downpayment());
         if(domain.getAnalytic_line_idsDirtyFlag())
            model.setAnalytic_line_ids(domain.getAnalytic_line_ids());
         if(domain.getPrice_reduce_taxincDirtyFlag())
            model.setPrice_reduce_taxinc(domain.getPrice_reduce_taxinc());
         if(domain.getQty_deliveredDirtyFlag())
            model.setQty_delivered(domain.getQty_delivered());
         if(domain.getDiscountDirtyFlag())
            model.setDiscount(domain.getDiscount());
         if(domain.getProduct_uom_qtyDirtyFlag())
            model.setProduct_uom_qty(domain.getProduct_uom_qty());
         if(domain.getPrice_reduceDirtyFlag())
            model.setPrice_reduce(domain.getPrice_reduce());
         if(domain.getCustomer_leadDirtyFlag())
            model.setCustomer_lead(domain.getCustomer_lead());
         if(domain.getProduct_updatableDirtyFlag())
            model.setProduct_updatable(domain.getProduct_updatable());
         if(domain.getQty_invoicedDirtyFlag())
            model.setQty_invoiced(domain.getQty_invoiced());
         if(domain.getUntaxed_amount_to_invoiceDirtyFlag())
            model.setUntaxed_amount_to_invoice(domain.getUntaxed_amount_to_invoice());
         if(domain.getNameDirtyFlag())
            model.setName(domain.getName());
         if(domain.getPrice_unitDirtyFlag())
            model.setPrice_unit(domain.getPrice_unit());
         if(domain.getCreate_dateDirtyFlag())
            model.setCreate_date(domain.getCreate_date());
         if(domain.getPurchase_line_countDirtyFlag())
            model.setPurchase_line_count(domain.getPurchase_line_count());
         if(domain.getName_shortDirtyFlag())
            model.setName_short(domain.getName_short());
         if(domain.getOption_line_idsDirtyFlag())
            model.setOption_line_ids(domain.getOption_line_ids());
         if(domain.getTax_idDirtyFlag())
            model.setTax_id(domain.getTax_id());
         if(domain.getSale_order_option_idsDirtyFlag())
            model.setSale_order_option_ids(domain.getSale_order_option_ids());
         if(domain.getPrice_subtotalDirtyFlag())
            model.setPrice_subtotal(domain.getPrice_subtotal());
         if(domain.getSequenceDirtyFlag())
            model.setSequence(domain.getSequence());
         if(domain.getPrice_totalDirtyFlag())
            model.setPrice_total(domain.getPrice_total());
         if(domain.getInvoice_linesDirtyFlag())
            model.setInvoice_lines(domain.getInvoice_lines());
         if(domain.getPurchase_line_idsDirtyFlag())
            model.setPurchase_line_ids(domain.getPurchase_line_ids());
         if(domain.getEvent_okDirtyFlag())
            model.setEvent_ok(domain.getEvent_ok());
         if(domain.getEvent_ticket_id_textDirtyFlag())
            model.setEvent_ticket_id_text(domain.getEvent_ticket_id_text());
         if(domain.getCreate_uid_textDirtyFlag())
            model.setCreate_uid_text(domain.getCreate_uid_text());
         if(domain.getLinked_line_id_textDirtyFlag())
            model.setLinked_line_id_text(domain.getLinked_line_id_text());
         if(domain.getOrder_partner_id_textDirtyFlag())
            model.setOrder_partner_id_text(domain.getOrder_partner_id_text());
         if(domain.getProduct_imageDirtyFlag())
            model.setProduct_image(domain.getProduct_image());
         if(domain.getCurrency_id_textDirtyFlag())
            model.setCurrency_id_text(domain.getCurrency_id_text());
         if(domain.getProduct_id_textDirtyFlag())
            model.setProduct_id_text(domain.getProduct_id_text());
         if(domain.getProduct_packaging_textDirtyFlag())
            model.setProduct_packaging_text(domain.getProduct_packaging_text());
         if(domain.getOrder_id_textDirtyFlag())
            model.setOrder_id_text(domain.getOrder_id_text());
         if(domain.getEvent_id_textDirtyFlag())
            model.setEvent_id_text(domain.getEvent_id_text());
         if(domain.getSalesman_id_textDirtyFlag())
            model.setSalesman_id_text(domain.getSalesman_id_text());
         if(domain.getProduct_uom_textDirtyFlag())
            model.setProduct_uom_text(domain.getProduct_uom_text());
         if(domain.getWrite_uid_textDirtyFlag())
            model.setWrite_uid_text(domain.getWrite_uid_text());
         if(domain.getCompany_id_textDirtyFlag())
            model.setCompany_id_text(domain.getCompany_id_text());
         if(domain.getStateDirtyFlag())
            model.setState(domain.getState());
         if(domain.getRoute_id_textDirtyFlag())
            model.setRoute_id_text(domain.getRoute_id_text());
         if(domain.getSalesman_idDirtyFlag())
            model.setSalesman_id(domain.getSalesman_id());
         if(domain.getCurrency_idDirtyFlag())
            model.setCurrency_id(domain.getCurrency_id());
         if(domain.getOrder_idDirtyFlag())
            model.setOrder_id(domain.getOrder_id());
         if(domain.getEvent_idDirtyFlag())
            model.setEvent_id(domain.getEvent_id());
         if(domain.getLinked_line_idDirtyFlag())
            model.setLinked_line_id(domain.getLinked_line_id());
         if(domain.getWrite_uidDirtyFlag())
            model.setWrite_uid(domain.getWrite_uid());
         if(domain.getCreate_uidDirtyFlag())
            model.setCreate_uid(domain.getCreate_uid());
         if(domain.getRoute_idDirtyFlag())
            model.setRoute_id(domain.getRoute_id());
         if(domain.getOrder_partner_idDirtyFlag())
            model.setOrder_partner_id(domain.getOrder_partner_id());
         if(domain.getProduct_uomDirtyFlag())
            model.setProduct_uom(domain.getProduct_uom());
         if(domain.getProduct_idDirtyFlag())
            model.setProduct_id(domain.getProduct_id());
         if(domain.getCompany_idDirtyFlag())
            model.setCompany_id(domain.getCompany_id());
         if(domain.getProduct_packagingDirtyFlag())
            model.setProduct_packaging(domain.getProduct_packaging());
         if(domain.getEvent_ticket_idDirtyFlag())
            model.setEvent_ticket_id(domain.getEvent_ticket_id());
        return model ;
    }

    public Sale_order_line convert2Domain( Isale_order_line model ,Sale_order_line domain) {
        if(model == null)
            return domain ;
        if(domain == null){
            domain = new Sale_order_line();
        }

        if(model.getIs_expenseDirtyFlag())
            domain.setIs_expense(model.getIs_expense());
        if(model.getWrite_dateDirtyFlag())
            domain.setWrite_date(model.getWrite_date());
        if(model.getQty_to_invoiceDirtyFlag())
            domain.setQty_to_invoice(model.getQty_to_invoice());
        if(model.getAnalytic_tag_idsDirtyFlag())
            domain.setAnalytic_tag_ids(model.getAnalytic_tag_ids());
        if(model.getWarning_stockDirtyFlag())
            domain.setWarning_stock(model.getWarning_stock());
        if(model.getIdDirtyFlag())
            domain.setId(model.getId());
        if(model.getDisplay_nameDirtyFlag())
            domain.setDisplay_name(model.getDisplay_name());
        if(model.getPrice_reduce_taxexclDirtyFlag())
            domain.setPrice_reduce_taxexcl(model.getPrice_reduce_taxexcl());
        if(model.getProduct_custom_attribute_value_idsDirtyFlag())
            domain.setProduct_custom_attribute_value_ids(model.getProduct_custom_attribute_value_ids());
        if(model.getQty_delivered_manualDirtyFlag())
            domain.setQty_delivered_manual(model.getQty_delivered_manual());
        if(model.getPrice_taxDirtyFlag())
            domain.setPrice_tax(model.getPrice_tax());
        if(model.getQty_delivered_methodDirtyFlag())
            domain.setQty_delivered_method(model.getQty_delivered_method());
        if(model.getInvoice_statusDirtyFlag())
            domain.setInvoice_status(model.getInvoice_status());
        if(model.getDisplay_typeDirtyFlag())
            domain.setDisplay_type(model.getDisplay_type());
        if(model.getMove_idsDirtyFlag())
            domain.setMove_ids(model.getMove_ids());
        if(model.getUntaxed_amount_invoicedDirtyFlag())
            domain.setUntaxed_amount_invoiced(model.getUntaxed_amount_invoiced());
        if(model.getProduct_no_variant_attribute_value_idsDirtyFlag())
            domain.setProduct_no_variant_attribute_value_ids(model.getProduct_no_variant_attribute_value_ids());
        if(model.get__last_updateDirtyFlag())
            domain.set__last_update(model.get__last_update());
        if(model.getIs_downpaymentDirtyFlag())
            domain.setIs_downpayment(model.getIs_downpayment());
        if(model.getAnalytic_line_idsDirtyFlag())
            domain.setAnalytic_line_ids(model.getAnalytic_line_ids());
        if(model.getPrice_reduce_taxincDirtyFlag())
            domain.setPrice_reduce_taxinc(model.getPrice_reduce_taxinc());
        if(model.getQty_deliveredDirtyFlag())
            domain.setQty_delivered(model.getQty_delivered());
        if(model.getDiscountDirtyFlag())
            domain.setDiscount(model.getDiscount());
        if(model.getProduct_uom_qtyDirtyFlag())
            domain.setProduct_uom_qty(model.getProduct_uom_qty());
        if(model.getPrice_reduceDirtyFlag())
            domain.setPrice_reduce(model.getPrice_reduce());
        if(model.getCustomer_leadDirtyFlag())
            domain.setCustomer_lead(model.getCustomer_lead());
        if(model.getProduct_updatableDirtyFlag())
            domain.setProduct_updatable(model.getProduct_updatable());
        if(model.getQty_invoicedDirtyFlag())
            domain.setQty_invoiced(model.getQty_invoiced());
        if(model.getUntaxed_amount_to_invoiceDirtyFlag())
            domain.setUntaxed_amount_to_invoice(model.getUntaxed_amount_to_invoice());
        if(model.getNameDirtyFlag())
            domain.setName(model.getName());
        if(model.getPrice_unitDirtyFlag())
            domain.setPrice_unit(model.getPrice_unit());
        if(model.getCreate_dateDirtyFlag())
            domain.setCreate_date(model.getCreate_date());
        if(model.getPurchase_line_countDirtyFlag())
            domain.setPurchase_line_count(model.getPurchase_line_count());
        if(model.getName_shortDirtyFlag())
            domain.setName_short(model.getName_short());
        if(model.getOption_line_idsDirtyFlag())
            domain.setOption_line_ids(model.getOption_line_ids());
        if(model.getTax_idDirtyFlag())
            domain.setTax_id(model.getTax_id());
        if(model.getSale_order_option_idsDirtyFlag())
            domain.setSale_order_option_ids(model.getSale_order_option_ids());
        if(model.getPrice_subtotalDirtyFlag())
            domain.setPrice_subtotal(model.getPrice_subtotal());
        if(model.getSequenceDirtyFlag())
            domain.setSequence(model.getSequence());
        if(model.getPrice_totalDirtyFlag())
            domain.setPrice_total(model.getPrice_total());
        if(model.getInvoice_linesDirtyFlag())
            domain.setInvoice_lines(model.getInvoice_lines());
        if(model.getPurchase_line_idsDirtyFlag())
            domain.setPurchase_line_ids(model.getPurchase_line_ids());
        if(model.getEvent_okDirtyFlag())
            domain.setEvent_ok(model.getEvent_ok());
        if(model.getEvent_ticket_id_textDirtyFlag())
            domain.setEvent_ticket_id_text(model.getEvent_ticket_id_text());
        if(model.getCreate_uid_textDirtyFlag())
            domain.setCreate_uid_text(model.getCreate_uid_text());
        if(model.getLinked_line_id_textDirtyFlag())
            domain.setLinked_line_id_text(model.getLinked_line_id_text());
        if(model.getOrder_partner_id_textDirtyFlag())
            domain.setOrder_partner_id_text(model.getOrder_partner_id_text());
        if(model.getProduct_imageDirtyFlag())
            domain.setProduct_image(model.getProduct_image());
        if(model.getCurrency_id_textDirtyFlag())
            domain.setCurrency_id_text(model.getCurrency_id_text());
        if(model.getProduct_id_textDirtyFlag())
            domain.setProduct_id_text(model.getProduct_id_text());
        if(model.getProduct_packaging_textDirtyFlag())
            domain.setProduct_packaging_text(model.getProduct_packaging_text());
        if(model.getOrder_id_textDirtyFlag())
            domain.setOrder_id_text(model.getOrder_id_text());
        if(model.getEvent_id_textDirtyFlag())
            domain.setEvent_id_text(model.getEvent_id_text());
        if(model.getSalesman_id_textDirtyFlag())
            domain.setSalesman_id_text(model.getSalesman_id_text());
        if(model.getProduct_uom_textDirtyFlag())
            domain.setProduct_uom_text(model.getProduct_uom_text());
        if(model.getWrite_uid_textDirtyFlag())
            domain.setWrite_uid_text(model.getWrite_uid_text());
        if(model.getCompany_id_textDirtyFlag())
            domain.setCompany_id_text(model.getCompany_id_text());
        if(model.getStateDirtyFlag())
            domain.setState(model.getState());
        if(model.getRoute_id_textDirtyFlag())
            domain.setRoute_id_text(model.getRoute_id_text());
        if(model.getSalesman_idDirtyFlag())
            domain.setSalesman_id(model.getSalesman_id());
        if(model.getCurrency_idDirtyFlag())
            domain.setCurrency_id(model.getCurrency_id());
        if(model.getOrder_idDirtyFlag())
            domain.setOrder_id(model.getOrder_id());
        if(model.getEvent_idDirtyFlag())
            domain.setEvent_id(model.getEvent_id());
        if(model.getLinked_line_idDirtyFlag())
            domain.setLinked_line_id(model.getLinked_line_id());
        if(model.getWrite_uidDirtyFlag())
            domain.setWrite_uid(model.getWrite_uid());
        if(model.getCreate_uidDirtyFlag())
            domain.setCreate_uid(model.getCreate_uid());
        if(model.getRoute_idDirtyFlag())
            domain.setRoute_id(model.getRoute_id());
        if(model.getOrder_partner_idDirtyFlag())
            domain.setOrder_partner_id(model.getOrder_partner_id());
        if(model.getProduct_uomDirtyFlag())
            domain.setProduct_uom(model.getProduct_uom());
        if(model.getProduct_idDirtyFlag())
            domain.setProduct_id(model.getProduct_id());
        if(model.getCompany_idDirtyFlag())
            domain.setCompany_id(model.getCompany_id());
        if(model.getProduct_packagingDirtyFlag())
            domain.setProduct_packaging(model.getProduct_packaging());
        if(model.getEvent_ticket_idDirtyFlag())
            domain.setEvent_ticket_id(model.getEvent_ticket_id());
        return domain ;
    }


}
